package com.ruoyi.boat.controller;

import java.util.List;

import com.ruoyi.boat.aop.AvoidDuplicate;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.boat.domain.AtmosData;
import com.ruoyi.boat.service.IAtmosDataService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 大气波导数据Controller
 *
 * @author ruoyi
 * @date 2023-08-09
 */
@Controller
@RequestMapping("/boat/atmosData")
public class AtmosDataController extends BaseController {
    private String prefix = "boat/atmosData";

    @Autowired
    private IAtmosDataService atmosDataService;

    @RequiresPermissions("boat:atmosData:view")
    @GetMapping()
    public String atmosData() {
        return prefix + "/atmosData";
    }

    /**
     * 查询大气波导数据列表
     */
    @RequiresPermissions("boat:atmosData:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AtmosData atmosData) {
        startPage();
        List<AtmosData> list = atmosDataService.selectAtmosDataList(atmosData);
        return getDataTable(list);
    }

    /**
     * 导出大气波导数据列表
     */
    @RequiresPermissions("boat:atmosData:export")
    @Log(title = "大气波导数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @AvoidDuplicate
    @ResponseBody
    public AjaxResult export(AtmosData atmosData) {
        List<AtmosData> list = atmosDataService.selectAtmosDataList(atmosData);
        ExcelUtil<AtmosData> util = new ExcelUtil<AtmosData>(AtmosData.class);
        return util.exportExcel(list, "大气波导数据");
    }

    /**
     * 新增大气波导数据
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存大气波导数据
     */
    @RequiresPermissions("boat:atmosData:add")
    @Log(title = "大气波导数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AtmosData atmosData) {
        return toAjax(atmosDataService.insertAtmosData(atmosData));
    }

    /**
     * 修改大气波导数据
     */
    @RequiresPermissions("boat:atmosData:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        AtmosData atmosData = atmosDataService.selectAtmosDataById(id);
        mmap.put("atmosData", atmosData);
        return prefix + "/edit";
    }

    /**
     * 修改保存大气波导数据
     */
    @RequiresPermissions("boat:atmosData:edit")
    @Log(title = "大气波导数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AtmosData atmosData) {
        return toAjax(atmosDataService.updateAtmosData(atmosData));
    }

    /**
     * 删除大气波导数据
     */
    @RequiresPermissions("boat:atmosData:remove")
    @Log(title = "大气波导数据", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(atmosDataService.deleteAtmosDataByIds(ids));
    }
}
